package com.ruoyi.system.api.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Aspect
@Component
public class TestAspect {
    @Around("@annotation(testAuth)")
    public Object testAround(ProceedingJoinPoint joinPoint, TestAuth testAuth) throws Throwable {
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        System.err.println(signature.getMethod().getName() + ": " + testAuth.value());
        Method method = signature.getMethod();
        TestAuth annotation = method.getAnnotation(TestAuth.class);
        String[] value = annotation.value();
        for (String s : value) {
            System.err.println(s);
        }
        return joinPoint.proceed();
    }
}
